﻿var http = require('http');
var url = require('url');
var router = require('./router');

var optfile = require('./module/optfile');
http.createServer(function(request, response){
	response.writeHead(200, {'Content-Type': 'text/html; chearset: utf-8'});
	if(request.url !== '/favicon.ico'){
		// optfile.readfileSync('./views/login.html');
		// optfile.readfile('./views/login.html', callBack);
		/*
		function callBack(data) {
			response.write(data);
			response.end('ok');
			response.end('ok');
		}
		*/
		var pathname = url.parse(request.url).pathname;
		pathname = pathname.replace(/\//, ''); // 替换掉前面的/
		router[pathname](request, response);
		
		console.log('主程序执行完毕');
	}
}).listen(8000);
console.log('server runing at http://192.168.178.7:8000')